home *** CD-ROM | disk | FTP | other *** search
- Path: news.cs.su.oz.au!metro!metro!extro!rblayney
- From: rblayney@extro.ucc.su.OZ.AU (Robert Blayney)
- Newsgroups: comp.lang.c
- Subject: newbie question concerning fread
- Date: 18 Feb 96 11:41:09 GMT
- Organization: Information Services, The University of Sydney, NSW, Australia
- Distribution: inet
- Message-ID: <rblayney.824643669@extro>
- NNTP-Posting-Host: extro.ucc.su.oz.au
- Summary: How to use the DATA array passed by fread
-
-
- Hi,
- I'm attempting to use the following function call
- fread(&result, sizeof(int), 16, fp);
- Unfortunately when I attempt to print the contents of the result array
- I obtain all zeros, where result is declared: int *result. I've tried successfully
- to use fgets which works on text files but really need to use fread. I'm not sure
- where the problem lies but when I've been printing the result array I've
- been using printf("%-6.2d", *(result + i));
- If anyone could offer me some advice about what I'm doing wrong I'd
- appreciate it.
-
- Extract:
- fseek(fp, 0L, SEEK_SET);
- bytesRead = fread(&result, sizeof (int), 16, fp);
-
- for (i = 0; i < bytesRead; i++) {
- printf("%-6.2d", *(result + i));
- }
-
- Many Thanks
- Rob
- (rblayney@extro.ucc.su.oz.au)
-